Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
image-type
Advanced tools
Detect the image type of a Buffer/Uint8Array
See the file-type module for more file types.
$ npm install --save image-type
$ bower install --save image-type
$ component install sindresorhus/image-type
var readChunk = require('read-chunk'); // npm install read-chunk
var imageType = require('image-type');
var buffer = readChunk.sync('unicorn.png', 0, 12);
imageType(buffer);
//=> png
var xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.png');
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
imageType(new Uint8Array(this.response));
//=> png
};
xhr.send();
Returns: png
, jpg
, gif
, webp
, tif
, bmp
, jxr
, psd
, false
SVG isn't included as it requires the whole file to be read, but you can get it here.
Type: buffer
(Node.js), uint8array
It only needs the first 12 bytes.
$ npm install --global image-type
$ image-type --help
Usage
$ cat <filename> | image-type
$ image-type <filename>
Example
$ cat unicorn.png | image-type
png
MIT © Sindre Sorhus
FAQs
Detect the image type of a Buffer/Uint8Array
The npm package image-type receives a total of 42,640 weekly downloads. As such, image-type popularity was classified as popular.
We found that image-type demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.